﻿using Downloader.Framework.Core;
using NHibernate.Linq;
using SharpArch.NHibernate;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Downloader.Framework.Queries
{
    public  class QueryBase: NHibernateQuery, IQueryBase
    {
        protected IQueryable<T> GetQuery<T>()
        {
            return Session.Query<T>();
        }

        public RecordList<T> GetList<T>(QueryParamsBase query) where T : EntityBase
        {
            return GetQuery<T>().GetList<T>(query);
        }


        public RecordList<S> GetList<T, S>(QueryParamsBase query)
            where T : EntityBase
            where S : IEntityConvert<T>, new()
        {
            return GetQuery<T>().GetModels<T, S>(query);
        }
    }
}
